﻿using AntdUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CKS.MES.Server.Demo
{
    public class PlcInfoUIItem : AntdUI.NotifyProperty
    {

        public PlcInfoUIItem(string name)
        {
            Code = name;
            Name = name;
            _btns = new AntdUI.CellLink[] {
                        new AntdUI.CellButton("read","复位",AntdUI.TTypeMini.Default),
                        new AntdUI.CellButton("write","复位",AntdUI.TTypeMini.Primary)
                    };
        }
        public int Id {  get; set; }
        private string _name;
        private AntdUI.CellTag[] _state;
        private int _successCount;

        public string Name
        {
            get => _name; set
            {
                _name = value;
                OnPropertyChanged("Name");
            }
        }

        public string Code { get; set; }

        public int OkCount {  get; set; }

        public int NgCount {  get; set; }

        
        public AntdUI.CellTag[] ConnectionState
        {
            get => _state; set
            {
                _state = value;
                OnPropertyChanged("ConnectionState");
            }
        }

        private CellBadge heartState;
        public CellBadge HeartState
        {
            get { return heartState; }
            set
            {
                if (heartState == value) return;
                heartState = value;
                OnPropertyChanged(nameof(HeartState));
            }
        }


        public int SuccessCount
        {
            get => _successCount; set
            {
                _successCount = value;
                OnPropertyChanged("SuccessCount");
            }
        }


        AntdUI.CellTag[] _tag;
        public AntdUI.CellTag[] tag
        {
            get => _tag;
            set
            {
                _tag = value;
                OnPropertyChanged("tag");
            }
        }

        AntdUI.CellLink[] _btns;
        private string connectionState;

        public AntdUI.CellLink[] btns
        {
            get => _btns;
            set
            {
                _btns = value;
                OnPropertyChanged("btns");
            }
        }

        public bool IsOnline { get; internal set; }
    }
}
